// JavaScript Document
var CURRENT_ASSET_TYPE = "";
function toMgrGrpPage()
{
	alert("Manage group button clicked!")	
}
function toCrtGrpPage()
{
	alert("New group button clicked!")	
}
function  startSearch()
{
	alert("Search: \nkeyword:'"+schr_kw_input.getValue()+"' \ntype:'"+c_l.value+"'");
}


comm_page = "assets_list.htm";
software_page = "assets_software.htm";
workstation_page = "assets_workstation.htm";
var ASSETS_TYPES = new Object();
ASSETS_TYPES[0] = {name:"Access point",page:comm_page};
ASSETS_TYPES[1] = {name:"Router",page:comm_page};
ASSETS_TYPES[2] = {name:"Printer",page:comm_page};
ASSETS_TYPES[3] = {name:"Switcher",page:comm_page};
ASSETS_TYPES[4] = {name:"Workstations",page:workstation_page};
ASSETS_TYPES[5] = {name:"Projector",page:comm_page};
ASSETS_TYPES[6] = {name:"Scanner",page:comm_page};
ASSETS_TYPES[7] = {name:"keyboards",page:comm_page};
ASSETS_TYPES[8] = {name:"Scaned Software",page:software_page};
ASSETS_TYPES[9] = {name:"Software Licenses",page:software_page};


function jumpAssetsPages(id)
{
	window.location = ASSETS_TYPES[id].page+"?type_id="+id
}

var pageLocation = window.location+"";
var module_id_mt = pageLocation.match(/type\_id\=([\d]+)/);
if(module_id_mt)
{
	CURRENT_ASSET_TYPE = ASSETS_TYPES[module_id_mt[1]].name;
}
else
{
	CURRENT_ASSET_TYPE = "Asste";
}
var asset_container_obj; 
if(asset_container_obj = document.getElementById("asset_name_str"))
{
	asset_container_obj.innerHTML = CURRENT_ASSET_TYPE;
}

	var manageGroupButton = new Ext.Button
	({
		renderTo:"manage_button_container",
		text:"Manage Groups",
		handler:toMgrGrpPage
	})
	var createGroupButton = new Ext.Button
	({
		renderTo:"create_button_container",
		text:"New Groups",
		handler:toCrtGrpPage
	})
	
	var schr_bt = new Ext.Button
	({
		renderTo:"schr_bt_container",
		text:"Search",
		handler:startSearch
	})
	
	
	var c_l = new Ext.form.ComboBox
	({
	 	renderTo:"combox_sch",
		maxLength :100,
		maxHeight :100,
		width:100,
		transform:"c_select",
		lazyRender:true,
		triggerAction: 'all',
		typeAhead: true,
		editable :false,
		listClass: 'x-combo-list-small'
	})
	
	var schr_kw_input = new Ext.form.TextField
	({
	 	renderTo:"schr_kw_container"
	})
	
	var panel_left = new Ext.Panel({
        
        collapsible:true,
        renderTo: 'left_content',
        width:"100%",
		border :false,
		items:
		[
			{
				title:_GR("assets_left_title_resource"),
				width:"100%",
				height:300,
				border :true,
				cls:"margin_5px",
				layout:'accordion',
                layoutConfig:
				{
                        animate:true
                },
				items:
				[
					{
						title:_GR("assets_left_ITA"),
						width:"100%",
						border :false,
						autoScroll :true,
						contentEl:"l_it_solution"
					},
					{
						title:_GR("assets_left_NITA"),
						width:"100%",
						border :false,
						autoScroll :true,
						contentEl:"l_no_it_solution"
					},
					{
						title:_GR("assets_left_AC"),
						width:"100%",
						border :false,
						autoScroll :true,
						contentEl:"l_asset_components"
					},
					{
						title:_GR("assets_left_S"),
						width:"100%",
						border :false,
						autoScroll :true,
						contentEl:"l_Software"
					},
					{
						title:_GR("assets_left_G"),
						width:"100%",
						border :false,
						autoScroll :true,
						contentEl:"l_group"
					}
				]
			},
			{
				title:_GR("assets_left_title_search"),
				width:"100%",
				height:111,
				border :true,
				cls: "margin_5px",
				contentEl:"search_container"
			}
		]
    });
	
	function AttacMouseEvent(parentNd)
	{
		if(!parentNd) return;
		var nodeArr = parentNd.childNodes;
		if(!nodeArr) return;
		for(var i=0;i<nodeArr.length;i++)
		{

			nodeArr[i].onmouseover = function()
			{
				this.style.backgroundColor = "#eeeeee";
				this.style.cursor = "pointer";
			}
			nodeArr[i].onmouseout = function()
			{
				this.style.backgroundColor = "";
			}
		}
	}
	AttacMouseEvent(document.getElementById("l_it_solution"));
	AttacMouseEvent(document.getElementById("l_no_it_solution"));
	AttacMouseEvent(document.getElementById("l_asset_components"));
	AttacMouseEvent(document.getElementById("l_Software"));
	